home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 58189 / 58189.xpi / chrome / content / statusbar.js < prev    next >
Text File  |  2010-01-06  |  2KB  |  64 lines

  1. /*
  2.  * This class provides the functions required by the status bar. These include
  3.  * recording feedback and enabling/disabling the policy decisions.
  4.  */
  5.  
  6. Components.utils.import("resource://csfiremodules/CsFireCommon.jsm");
  7.  
  8. CsFire.StatusBar = new function() {
  9.     this.window = null;
  10. };
  11.  
  12. /*
  13.  * This function makes sure the menu is shown when the statusbar is clicked
  14.  */
  15. CsFire.StatusBar.onPanelClick = function() {
  16.     try {
  17.         var anchor = document.getElementById("csfirePanel");
  18.         document.getElementById("csfireStatusMenu").openPopup(anchor, "before_start", 0, 0, true, false);
  19.     }
  20.     catch(ex) { }
  21. }
  22.  
  23. /*
  24.  * This function handles a click on the whitelist button
  25.  */
  26. CsFire.StatusBar.onWhitelistClick = function() {
  27.     this.window = window.open("chrome://csfire/content/whitelist.xul", "CsFire Whitelist", "chrome");
  28. }
  29.  
  30. /*
  31.  * This function initializes the loading, by setting the policy status variables
  32.  * and status bar icons
  33.  */
  34. CsFire.StatusBar.onActivateLoad = function() {
  35.     var active = CsFire.PolicyManager.isEnabled();
  36.     
  37.     // Retrieve the XUL element
  38.     var element = document.getElementById("csfirePanel");
  39.  
  40.     if(active) {
  41.         element.label = "CsFire";
  42.         element.tooltip = "CsFire Protection Enabled";
  43.         var style = element.style;
  44.         style['color'] = "green";
  45.     }
  46.     else {
  47.         element.label = "CsFire";
  48.         element.tooltip = "CsFire Protection Disabled";
  49.         var style = element.style;
  50.         style['color'] = "red";
  51.     }
  52. }
  53.  
  54. /*
  55.  * This function switches the status of the policy (enabled/disabled)
  56.  */
  57. CsFire.StatusBar.onActivateClick = function() {
  58.     CsFire.PolicyManager.switchEnabledStatus();
  59.     this.onActivateLoad();
  60. }
  61.  
  62. //Set the statusbar field
  63. window.addEventListener("load", function(e) { CsFire.StatusBar.onActivateLoad(); }, false);
  64.